// SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
// SPDX-License-Identifier: Mulan PSL v2
package handler

import (
	"github.com/gin-gonic/gin"

	"code.geniusai.org/notebook-manager/pkg/entity"
	"code.geniusai.org/notebook-manager/pkg/resource"
)

type PvcHandler struct {
	resourceManager *resource.Manager
}

func NewPvcHandler(resourceManager *resource.Manager) *PvcHandler {
	return &PvcHandler{resourceManager}
}

// 获取存储列表
// @Summary 获取存储列表
// @Description 获取存储列表
// @Tags 存储管理
// @Accept  json
// @Produce  json
// @Param userID path    string true "default"
// @Param pageSize query int true "default 0"
// @Param pageNum  query int true "default 0"
// @Param keyword  query string true "default "
// @Success 200 {object} entity.HttpRespond{data=entity.HttpRespondList} "按时间倒序排序"
// @Failure 200 {object} entity.HttpRespond
// @Router /users/{userID}/pvcs [get]
func (n *PvcHandler) List(c *gin.Context) error {
	option := &entity.UserListOption{}
	err := c.ShouldBindQuery(option)
	if err != nil {
		return entity.NewCodeError(entity.CodeSystemError)
	}
	option.UserID = c.Param("userID")
	total, list, err := n.resourceManager.ListPvc(option)
	if err != nil {
		return entity.NewCodeError(entity.CodeSystemError)
	}
	success(c, entity.HttpRespondList{
		List:  list,
		Total: total,
	})
	return nil
}

func (n *PvcHandler) Delete(c *gin.Context) error {
	return nil
}
